<@override name="page-title">
添加学校
</@override>
<@override name="page-style">
<link rel="stylesheet" href="/assets/admin/css/plugins/file-upload/bootstrap-fileupload.css">
</@override>
<@override name="page-body">

<div class="ibox-content">
    <form class="form-horizontal m-t" id="updateForm" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-xs-3 control-label">学校名称：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" value="" id="name" name="name"
                       placeholder="请输入学校名称"
                       minlength="2" required="" aria-required="true">
            </div>
        </div>

        <div class="form-group">
            <label class="col-xs-3 control-label">学校类型：</label>
            <div class="col-xs-8">
                <select class="form-control" name="category">
                    <#list typeList as type>
                        <option value="${type}" <#if type_index == 0>selected</#if>>${type.desc}</option>
                    </#list>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">学校简介：</label>
            <div class="col-xs-8">
                <textarea class="form-control" id="summary" name="summary" rows="3"
                          placeholder="请输入学校简介"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">省份：</label>
            <div class="col-xs-8">
                <select class="form-control" name="provinceId">
                    <#list provinceList as province>
                        <option value="${province.id}" <#if type_index == 0>selected</#if>>${province.name}</option>
                    </#list>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">学校城市：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" value="" id="city" name="city"
                       placeholder="请输入学校城市"
                       minlength="2" required="" aria-required="true">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">学校地址：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" value="" id="address" name="address"
                       placeholder="请输入学校地址"
                       minlength="2" required="" aria-required="true">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">展示顺序：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" value="" id="displayOrder" name="displayOrder"
                       placeholder="请输入展示顺序"
                       minlength="1" required="" aria-required="true">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">学校图片：</label>
            <div class="col-xs-8">
                <div class="fileupload fileupload-new" data-provides="fileupload">
                    <div class="btn-group">
                        <label title="上传图片" for="fileupload" class="btn btn-primary">
                            <input type="file" accept="image/*" name="file" id="fileupload" class="hide">上传图片
                        </label>
                    </div>
                    <div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
                        <img src="/assets/admin/img/noimage.jpg" alt="">
                    </div>
                    <div class="fileupload-preview fileupload-exists thumbnail" id="imgDiv"
                         style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-12 col-xs-offset-4">
                <button class="btn btn-primary" type="submit">保存</button>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <button onClick="layer_close();" class="btn btn-default radius" type="button">
                    取消
                </button>
            </div>
        </div>
    </form>
</div>
</@override>
<@override name="page-script">
<script type="text/javascript" src="/assets/admin/js/plugins/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="/assets/admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/assets/admin/js/plugins/file-upload/bootstrap-fileupload.js"></script>
<script src="/assets/admin/js/plugins/jquery-form/jquery.form.js"></script>
<script type="text/javascript">
    $(function () {
        $("#updateForm").validate({
            submitHandler: function (form) {
                var index = parent.layer.getFrameIndex(window.name);
                $(form).ajaxSubmit({
                    url: "/admin/school/save.json",
                    type: "POST",
                    success: function (data) {
                        if (data.ret) {
                            parent.$("#layer-data").val('1');
                        } else {
                            parent.$("#layer-data").val(data.errmsg);
                        }
                        parent.layer.close(index);
                    }
                });
            }
        })
    })
    ;
</script>
</@override>
<@extends name="admin/common/common.ftl"/>